<?php namespace Home\Controller; 

class GotoorderController extends CommonController{
	public function index(){
		$data = Cart::getGoods(); 
		$id = Cart::getOrderId();
		$sum = Cart::getTotalPrice();
		$tid = Cart::getOrderId();
		foreach ($data as $k => $v) {
			$data[$k]['g_pic'] = Db::table("360mall_goods")->where("g_id",$v['id'])->pluck("g_pic");
		$data[$k]['sum']=$sum;	
		$data[$k]['tid']=$tid;	
		$data[$k]['total_rows']= $_SESSION['cart']['total_rows'];
		}
		$address = Db::table("360mall_address")->where("ad_uid",$_SESSION['uid'])->get();
//      p($address);
		View::with("address",$address);
	    View::with("data",$data);
		View::make();
	}
	public function Addaddress(){
		if(IS_AJAX){
			$addModel =new  \Common\Model\Address;
			$data =array(
			   "ad_consignee"=>$_POST['consignee'],
			   "ad_address"=>$_POST['address'],
			   "ad_detail"=>$_POST['detail'],
			   "ad_PC"=>$_POST['pc'],
			   "ad_phone"=>$_POST['phone'],
			   "ad_uid"=>$_SESSION['uid'],
			);
			$addModel->add($data);
			echo json_encode($data);
		}
	}
}